package com.febers.ihealth.entity

import com.febers.ihealth.utils.IOUtil
import com.febers.ihealth.utils.addOrRemove
import com.febers.ihealth.utils.illnessList

class UserBean {

    var name = ""
    var pw = ""
    var age = ""
    var male = true
    var preg = false
    var height = ""
    var weight = ""
    var temp = ""
    var heart = ""
    var pressure = ""
    var fluTimes = ""

    fun registered(): Boolean {
        return name.isNotEmpty() && pw.isNotEmpty()
    }

    fun baseInfoFinish(): Boolean {
        return age.isNotEmpty() && height.isNotEmpty() && weight.isNotEmpty()
                && temp.isNotEmpty()&& heart.isNotEmpty() && pressure.isNotEmpty() && fluTimes.isNotEmpty()
    }

    fun clearBaseInfo() {
        name = ""
        pw = ""
        age = ""
        male = true
        preg = false
        height = ""
        weight = ""
        temp = ""
        heart = ""
        pressure = ""
        IOUtil.clearUser()
    }

    //第一页
    var fare = false
    var fumai = false
    var pentiBisaiLiuti = false
    var ehanEfeng = false
    var toutongJiroutengtongGujietengtong = false
    var kesouQichuan = false
    var yanganYantongYanyang = false
    var wanglaihanre = false

    var bufare = !fare
    var toutong = toutongJiroutengtongGujietengtong
    var bisai = pentiBisaiLiuti
    var wubisai = !pentiBisaiLiuti
    var buefenghan = !ehanEfeng
    fun clearBeforeSurvey() {
        fumai = false
        pentiBisaiLiuti = false
        ehanEfeng = false
        toutongJiroutengtongGujietengtong = false
        kesouQichuan = false
        yanganYantongYanyang = false
        wanglaihanre = false
        illnessList.clear()
    }

    //出汗情况
    var wuhan = false
        set(value) {
            field = value
            illnessList.addOrRemove("发热，无汗", value)
        }
    var weihan = false
        set(value) {
            field = value
            illnessList.addOrRemove("发热，微汗", value)
        }
    var zhengchanghan = false
        set(value) {
            field = value
            illnessList.addOrRemove("发热、正常汗", value)
        }
    var baitianhan = false
        set(value) {
            field = value
            illnessList.addOrRemove("发热、白天多汗", value)
        }
    var yejianhan = false
        set(value) {
            field = value
            illnessList.addOrRemove("发热、盗汗（夜间出汗）", value)
        }
    var zhengchanghanBufare = false
        set(value) {
            field = value
            illnessList.addOrRemove("不发热、正常汗", value)
        }
    var baitianhanBufare = false
        set(value) {
            field = value
            illnessList.addOrRemove("不发热、白天多汗", value)
        }
    var yejianhanBufare = false
        set(value) {
            field = value
            illnessList.addOrRemove("不发热、盗汗（夜间出汗）", value)
        }

    var youhan = !wuhan
    var duohan = baitianhan
    fun clearChuhan() {
        wuhan = false
        weihan = false
        zhengchanghan = false
        baitianhan = false
        yejianhan = false
        zhengchanghanBufare = false
        baitianhanBufare = false
        yejianhanBufare = false
    }

    //如果有恶风恶寒
    var yanzhongEhan = false
        set(value) {
            field = value
            illnessList.addOrRemove("严重恶寒（特别怕冷）", value)
        }
    var weieFenghan = false
        set(value) {
            field = value
            illnessList.addOrRemove("微恶风寒", value)
        }
    var eFenghan = false
        set(value) {
            field = value
            illnessList.addOrRemove("恶风寒", value)
        }
    var eFeng = false
        set(value) {
            field = value
            illnessList.addOrRemove("恶风", value)
        }
    fun clearEfengEhan() {
        yanzhongEhan = false
        weieFenghan = false
        eFenghan = false
        eFeng = false
//        illnessList.addOrRemove("严重恶寒（特别怕冷）", false)
//        illnessList.addOrRemove("微恶风寒", false)
//        illnessList.addOrRemove("恶风寒", false)
//        illnessList.addOrRemove("恶风", false)
    }

    //如果有发热
    var chixuGaore = false
        set(value) {
            field = value
            illnessList.addOrRemove("持续高热", value)
        }
    var chixuZhongre = false
        set(value) {
            field = value
            illnessList.addOrRemove("持续中热", value)
        }
    var chixuDire = false
        set(value) {
            field = value
            illnessList.addOrRemove("持续低热", value)
        }
    var wuhouChaore = false
        set(value) {
            field = value
            illnessList.addOrRemove("午后潮热", value)
        }
    var zaochenFare = false
        set(value) {
            field = value
            illnessList.addOrRemove("早晨发热", value)
        }
    var yejianFare = false
        set(value) {
            field = value
            illnessList.addOrRemove("夜间发热", value)
        }
    var fareBuguilv = false
        set(value) {
            field = value
            illnessList.addOrRemove("发热时间不规律", value)
        }
    var shenreZhihan = false
        set(value) {
            field = value
            illnessList.addOrRemove("身热肢寒", value)
        }
    fun clearFare() {
        chixuGaore = false
        chixuZhongre = false
        chixuDire = false
        wuhouChaore = false
        zaochenFare = false
        yejianFare = false
        fareBuguilv = false
        shenreZhihan = false
    }

    var youqichuan = false
        set(value) {
            field = value
            illnessList.addOrRemove("气喘", value)
        }
    var wuqichuan = false
        set(value) {
            field = value
            illnessList.addOrRemove("无气喘", value)
        }

    //如果有咳嗽
    var ketanQingxi = false
        set(value) {
            field = value
            illnessList.addOrRemove("咳痰清稀", value)
        }
    var ketanHuangchou = false
        set(value) {
            field = value
            illnessList.addOrRemove("咳痰黄稠", value)
        }
    var yiKechu = false
        set(value) {
            field = value
            illnessList.addOrRemove("白痰，易咳出", value)
        }
    var nanKechu = false
        set(value) {
            field = value
            illnessList.addOrRemove("痰少，难咳出", value)
        }
    var wutanGanke = false
        set(value) {
            field = value
            illnessList.addOrRemove("无痰，干咳", value)
        }
    
    var kesou = kesouQichuan
    fun clearKesou() {
        ketanQingxi = false
        ketanHuangchou = false
        yiKechu = false
        nanKechu = false
        wutanGanke = false
    }

    //如果有头痛
    var diandingtong = false
        set(value) {
            field = value
            illnessList.addOrRemove("颠顶痛", value)
        }
    var zuoceToutong = false
        set(value) {
            field = value
            illnessList.addOrRemove("偏头痛（仅左侧）", value)
        }
    var youceToutong = false
        set(value) {
            field = value
            illnessList.addOrRemove("偏头痛（仅右侧）", value)
        }
    var hounaotong = false
        set(value) {
            field = value
            illnessList.addOrRemove("后脑痛（颈项僵痛）", value)
        }
    var etoutong = false
        set(value) {
            field = value
            illnessList.addOrRemove("额头痛", value)
        }
    var meilenggutong = false
        set(value) {
            field = value
            illnessList.addOrRemove("眉棱骨痛", value)
        }
    var wuweizhiToutong = false
        set(value) {
            field = value
            illnessList.addOrRemove("头痛，但无明确位置", value)
        }

    var piantoutong = zuoceToutong || youceToutong
    fun clearToutong() {
        diandingtong = false
        zuoceToutong = false
        youceToutong = false
        hounaotong = false
        etoutong = false
        meilenggutong = false
        wuweizhiToutong = false
    }
    fun checkToutongFinish(): Boolean {
        if (!toutongJiroutengtongGujietengtong) {
            return true
        }
        return diandingtong || zuoceToutong || youceToutong || hounaotong || etoutong || meilenggutong || wuweizhiToutong
    }

    var jiroutengtong = false
        set(value) {
            field = value
            illnessList.addOrRemove("肌肉疼痛", value)
        }
    var jingxiangtengtong = false
        set(value) {
            field = value
            illnessList.addOrRemove("颈项疼痛", value)
        }
    var guanjietengtong = false
        set(value) {
            field = value
            illnessList.addOrRemove("关节疼痛", value)
        }
    var shentongwuzhiwei = false
        set(value) {
            field = value
            illnessList.addOrRemove("身痛，但无明显位置", value)
        }

    //流涕
    var bitiQing = false
        set(value) {
            field = value
            illnessList.addOrRemove("清鼻涕", value)
        }
    var bitiBai = false
        set(value) {
            field = value
            illnessList.addOrRemove("浓稠鼻涕白色", value)
        }
    var bitiHuang = false
        set(value) {
            field = value
            illnessList.addOrRemove("浓稠鼻涕黄色", value)
        }
    var biganBizao = false
        set(value) {
            field = value
            illnessList.addOrRemove("鼻干、鼻燥", value)
        }
    var bise = false
        set(value) {
            field = value
            illnessList.addOrRemove("鼻塞", value)
        }
    var penti = false
        set(value) {
            field = value
            illnessList.addOrRemove("喷嚏", value)
        }
    var biYang = false
        set(value) {
            field = value
            illnessList.addOrRemove("鼻痒", value)
        }
    var wuti = !pentiBisaiLiuti
    fun clearLiuti() {
        bitiQing = false
        bitiBai = false
        bitiHuang = false
        biganBizao = false
    }

    var yangan = false
        set(value) {
            field = value
            illnessList.addOrRemove("咽干", value)
        }
    var yantong = false
        set(value) {
            field = value
            illnessList.addOrRemove("咽痛", value)
        }
    var yanyang = false
        set(value) {
            field = value
            illnessList.addOrRemove("咽痒", value)
        }

    //胃肠道症状
    /**
     * A恶心
    B呕吐
    C便溏
    D腹泻
    E水样便
    F腹胀
    G食欲差
    H无食欲
    I便秘
    CD互斥，CE互斥，GH互斥，I与CDE互斥
     */
    var exin = false
        set(value) {
            field = value
            illnessList.addOrRemove("恶心", value)
        }
    var outu = false
        set(value) {
            field = value
            illnessList.addOrRemove("呕吐", value)
        }
    var biantang = false
        set(value) {
            field = value
            illnessList.addOrRemove("便溏", value)
        }
    var fuxie = false
        set(value) {
            field = value
            illnessList.addOrRemove("腹泻", value)
        }
    var shuiyangbian = false
        set(value) {
            field = value
            illnessList.addOrRemove("水样便", value)
        }
    var fuzhang = false
        set(value) {
            field = value
            illnessList.addOrRemove("腹胀", value)
        }
    var shiyucha = false
        set(value) {
            field = value
            illnessList.addOrRemove("食欲差", value)
        }
    var wushiyu = false
        set(value) {
            field = value
            illnessList.addOrRemove("无食欲", value)
        }
    var bianmi = false
        set(value) {
            field = value
            illnessList.addOrRemove("便秘", value)
        }

    /**
     * 腹痛
    胸胁胀满
    胁痛
    胸闷
    头重
    身重
     */
    var futong = false
        set(value) {
            field = value
            illnessList.addOrRemove("腹痛", value)
        }
    var xiongxiezhangman = false
        set(value) {
            field = value
            illnessList.addOrRemove("胸胁胀痛", value)
        }
    var xietong = false
        set(value) {
            field = value
            illnessList.addOrRemove("胁痛", value)
        }
    var xiongmen = false
        set(value) {
            field = value
            illnessList.addOrRemove("胸闷", value)
        }
    var touzhong = false
        set(value) {
            field = value
            illnessList.addOrRemove("头重", value)
        }
    var shenzhong = false
        set(value) {
            field = value
            illnessList.addOrRemove("身重", value)
        }
    var juandai = false
        set(value) {
            field = value
            illnessList.addOrRemove("倦怠", value)
        }
    var xinfan = false
        set(value) {
            field = value
            illnessList.addOrRemove("心烦", value)
        }

    /**
     * A小便黄
    B小便少
    C小便清长
    D夜尿多

    C与AB互斥，
     */
    var niaohuang = false
        set(value) {
            field = value
            illnessList.addOrRemove("小便黄", value)
        }
    var niaoshao = false
        set(value) {
            field = value
            illnessList.addOrRemove("小便少", value)
        }
    var niaoqingchang = false
        set(value) {
            field = value
            illnessList.addOrRemove("小便清长", value)
        }
    var yeniaoduo = false
        set(value) {
            field = value
            illnessList.addOrRemove("夜尿多", value)
        }

    /**
     * 6.3
    A口苦
    B口不渴
    C口渴饮多
    D口干不欲饮
    E喜冷饮
    F喜热饮

    BCD互斥，EF互斥
     */
    var kouku = false
        set(value) {
            field = value
            illnessList.addOrRemove("口苦", value)
        }
    var koubuke = false
        set(value) {
            field = value
            illnessList.addOrRemove("口不渴", value)
        }
    var koukeyinduo = false
        set(value) {
            field = value
            illnessList.addOrRemove("口渴饮多", value)
        }
    var kouganbuyuyin = false
        set(value) {
            field = value
            illnessList.addOrRemove("口干不欲饮", value)
        }
    var xilengyin = false
        set(value) {
            field = value
            illnessList.addOrRemove("喜冷饮", value)
        }
    var xireyin = false
        set(value) {
            field = value
            illnessList.addOrRemove("喜热饮", value)
        }

    /**
     * 7.1舌质
    A舌质淡白
    B舌边尖红
    C舌质黯红
    D舌质红
    E舌有齿痕
    F舌质干
    G舌水滑

    ABCD互斥
    F和G互斥
     */
    var shezhibai = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌质淡白", value)
        }
    var shebianjianhong = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌质尖红", value)
        }
    var shezhianhong = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌质黯红", value)
        }
    var shezhihong = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌质红", value)
        }
    fun clearShezhi() {
        shezhibai = false
        shebianjianhong = false
        shezhianhong = false
        shezhihong = false
    }

    var shechihen = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌有齿痕", value)
        }
    var shezhigan = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌质干", value)
        }
    var sheshuihua = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌水滑", value)
        }

    /**
    7.2舌苔
    A舌苔白
    B舌苔黄
    C舌苔厚
    D舌苔薄
    E舌苔少
    F无舌苔
    G舌苔腻
    H舌苔腐

    CDE互斥，GH互斥
    F与其它互斥
     */
    var shetaibai = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌苔白", value)
        }
    var shetaihuang = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌苔黄", value)
        }

    var shetaihou = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌苔厚", value)
        }
    var shetaibao = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌苔薄", value)
        }
    var shetaishao = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌苔少", value)
        }
    fun clearSheTaihoudu() {
        shetaihou = false
        shetaibao = false
        shetaishao = false
    }
    var shetaiwu = false
        set(value) {
            field = value
            illnessList.addOrRemove("无舌苔", value)
        }
    var shetaini = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌苔腻", value)
        }
    var shetaifu = false
        set(value) {
            field = value
            illnessList.addOrRemove("舌苔腐", value)
        }
    fun clearSheTai() {
        shetaibai = false
        shetaihuang = false
        shetaihou = false
        shetaibao = false
        shetaishao = false
        shetaiwu = false
        shetaini = false
        shetaifu = false
    }

    /**
     * A脉浮
    B脉沉
    C脉数
    D脉迟
    E脉滑
    F脉弦

    AB互斥
    CD互斥
     */
    var maifu = false
        set(value) {
            field = value
            illnessList.addOrRemove("脉浮", value)
        }
    var maichen = false
        set(value) {
            field = value
            illnessList.addOrRemove("脉沉", value)
        }
    var maishu = false
        set(value) {
            field = value
            illnessList.addOrRemove("脉数", value)
        }
    var maichi = false
        set(value) {
            field = value
            illnessList.addOrRemove("脉迟", value)
        }
    var maihua = false
        set(value) {
            field = value
            illnessList.addOrRemove("脉滑", value)
        }
    var maixian = false
        set(value) {
            field = value
            illnessList.addOrRemove("脉弦", value)
        }
}